import { useRouter } from 'vue-router';
import { fetchMenuTree } from '@/api/user';
import { localStorageGet } from '@/utils/localStorage';
import { USER } from '@/constant/storage';

export const useMemuStore = defineStore('memu', {
  // 静态数据
  state: () => ({
    memuList: [],
  }),
  // actions即可以是同步函数也可以是异步函数
  actions: {
    async getMemuList() {
      const userInfo = localStorageGet(USER);
      const accountId = userInfo.sso_user_id;
      const params = {
        accountId,
        systemCode: 'VSKSH',
        functionTypes: ['MODULE', 'MENU'],
        status: 'ENABLED',
      };
      const res = await fetchMenuTree(params);
      this.memuList = res;
    },
  },
});
